package com.swiftride.autoconfigure;

import com.swiftride.config.SaTokenConfig;
import com.swiftride.config.StpInterfaceImpl;
import com.swiftride.interceptor.FeignTokenInterceptor;
import com.swiftride.properties.SaTokenStpProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;

@Configuration
@EnableConfigurationProperties({SaTokenStpProperties.class})
public class SaTokenAutoConfiguration {

    @Bean
    public SaTokenConfig saTokenConfig() {
        return new SaTokenConfig();
    }

    @Bean
    public StpInterfaceImpl stpInterface(RedisTemplate<String, Object> redisTemplate, SaTokenStpProperties saTokenStpProperties) {
        return new StpInterfaceImpl(redisTemplate, saTokenStpProperties);
    }

    @Bean
    public FeignTokenInterceptor feiTokenInterceptor() {
        return new FeignTokenInterceptor();
    }
}
